package redis.gambing;

import org.apache.storm.redis.common.mapper.RedisDataTypeDescription;
import org.apache.storm.redis.common.mapper.RedisStoreMapper;
import org.apache.storm.tuple.ITuple;

import static redis.gambing.GambleFinalString.GAMBLER_ID;
import static redis.gambing.GambleFinalString.HASH_GAMBLER_3_ASSERTS;

public class GamblerAssertsInfoStoreMapper implements RedisStoreMapper {
    private final RedisDataTypeDescription description;

    public GamblerAssertsInfoStoreMapper() {
        description = new RedisDataTypeDescription(RedisDataTypeDescription.RedisDataType.HASH, HASH_GAMBLER_3_ASSERTS);
    }

    @Override
    public RedisDataTypeDescription getDataTypeDescription() {
        return description;
    }

    @Override
    public String getKeyFromTuple(ITuple tuple) {
        return tuple.getStringByField(GAMBLER_ID);
    }

    @Override
    public String getValueFromTuple(ITuple tuple) {
        return Long.toString(tuple.getLongByField(HASH_GAMBLER_3_ASSERTS));
    }
}
